package com.system.manager;

import com.common.core.constants.CacheConstants;
import com.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class QuestionCacheManager {

    @Autowired
    private RedisService redisService;

    public void addCache(Long questionId) {
        redisService.leftPushForList(CacheConstants.QUESTION_LIST, questionId);
    }

    public void deleteCache(Long questionId) {
        redisService.removeForList(CacheConstants.QUESTION_LIST, questionId);
    }

    public void refreshCache() {
        // 清空旧的缓存
        redisService.deleteObject(CacheConstants.QUESTION_LIST);
        // 通知friend模块刷新缓存
        // 这里可以添加调用friend模块刷新接口的逻辑
        // 例如通过Feign客户端调用friend模块的刷新接口
    }
}